package edu.ncsu.monopoly.logic.cells;

import edu.ncsu.monopoly.logic.GameMaster;
import edu.ncsu.monopoly.logic.entities.Player;

public class PropertyCell extends Cell {
	private String colorGroup;
	private int housePrice;
	private int numberOfHouses;
	private int rent;
	private int sellPrice;

	public String getColorGroup() {
		return colorGroup;
	}

	public int getHousePrice() {
		return housePrice;
	}

	public int getHousesCount() {
		return numberOfHouses;
	}
    
    public int getPrice() {
		return sellPrice;
	}
    
	public int getRent(int parameter) {
		int rentToCharge = (parameter == 0) ? rent : rent * Cell.InflationParameter;
		
		String [] monopolies = owner.getMonopolies();
		for(int i = 0; i < monopolies.length; i++) {
			if(monopolies[i].equals(colorGroup)) {
				rentToCharge = rent * 2;
			}
		}
		if(numberOfHouses > 0) {
			rentToCharge = rent * (numberOfHouses + 1);
		}
		return rentToCharge;		
	}

	public void playAction() {
		Player currentPlayer = null;
		if(!isAvailable()) {
			currentPlayer = GameMaster.instance().getCurrentPlayer();
			if(owner != currentPlayer) {
				currentPlayer.payRentTo(owner, getRent(Cell.InflationParameter));
			}
		}
	}

	public void setColorGroup(String colorGroup) {
		this.colorGroup = colorGroup;
	}

	public void setHousePrice(int housePrice) {
		this.housePrice = housePrice;
	}

	public void setNumberOfHouses(int numHouses) {
		this.numberOfHouses = numHouses;
	}
	
	public int getNumberOfHouses(){
		return this.numberOfHouses;
	}

	public void setPrice(int sellPrice) {
		this.sellPrice = sellPrice;
	}

	public void setRent(int rent) {
		this.rent = rent;
	}
}
